<template>
    <el-form :model="formData" :inline="true" label-width="auto">
        <el-form-item v-for="colitem in cols" :label="colitem.Field" :prop="colitem.Field" :data-type="colitem.Type">
            <el-input v-model="formData[colitem.Field]"></el-input>
        </el-form-item>
        <slot name="default"></slot>
    </el-form>
</template>
<script>
import { cloneDeep } from 'lodash-es'
export default {
    data() {
        var cols = this.$props.props_cols || []
        var ignore_cols = (this.$props.props_ignore_cols || [])
        var colFilter = cols.filter(item => !((ignore_cols || []).includes(item.Field)))
        return {
            cols: colFilter,
            formData: this.$props.model,
        }
    },
    props: {
        model: {
            type: [Object]
        },
        props_cols: {
            type: [Array]
        }, props_ignore_cols: {
            type: [Array]
        }
    },
    methods: {
        initByDialog(_data) {
            var cols = _data?.cols || this.$props.props_cols;
            this.formData = _data?.formData || this.$props.model

            var ignore_cols = (this.$props.props_ignore_cols || [])
            var colFilter = cols.filter(item => !((ignore_cols || []).includes(item.Field)))
            this.cols = colFilter

        },
        submitByDialog() {
            return { success: true, data: this.formData }
        }
    }
}

</script>